<html>
<head><meta charset="utf-8"><title>rustdoc ignore not working · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html">rustdoc ignore not working</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213741787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213741787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213741787">(Oct 19 2020 at 04:15)</a>:</h4>
<p>Why is <code>ignore</code> not working here?</p>
<div class="codehilite"><pre><span></span><code>warning: could not parse code block as Rust code
  --&gt; compiler/rustc_trait_selection/src/opaque_types.rs:44:9
   |
44 |       /// ```ignore (incomplete snippet)
   |  _________^
45 | |     /// type Foo = impl Baz;
46 | |     /// fn bar() -&gt; Foo {
47 | |     /// //          ^^^ This is the span we are looking for!
48 | |     /// ```
   | |___________^
   |
   = note: error from rustc: this file contains an unclosed delimiter
</code></pre></div>



<a name="213741846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213741846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213741846">(Oct 19 2020 at 04:17)</a>:</h4>
<p>(Note: I posted about this on #rustdoc on Discord last week, but I didn't get any replies. It may have been because the formatting was horrible since Discord doesn't seem to have a way to escape backticks <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span>)</p>



<a name="213741965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213741965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213741965">(Oct 19 2020 at 04:19)</a>:</h4>
<blockquote>
<p>I didn't get any replies</p>
</blockquote>
<p>I'd have to read the code to tell you :/</p>



<a name="213742194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213742194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213742194">(Oct 19 2020 at 04:25)</a>:</h4>
<p>Which code? The code that caused the error is in the error message. Unless you mean "I need to read the rustdoc source code"...</p>



<a name="213742206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213742206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213742206">(Oct 19 2020 at 04:26)</a>:</h4>
<p>Here's the code by itself:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="sd">/// ```ignore (incomplete snippet)</span>
<span class="sd">/// type Foo = impl Baz;</span>
<span class="sd">/// fn bar() -&gt; Foo {</span>
<span class="sd">/// //          ^^^ This is the span we are looking for!</span>
<span class="sd">/// ```</span>
</code></pre></div>



<a name="213742260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213742260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213742260">(Oct 19 2020 at 04:27)</a>:</h4>
<p>For reference, I think this section of rustdoc source code is responsible for parsing the lang string:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">tokens</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">string</span><span class="p">.</span><span class="n">split</span><span class="p">(</span><span class="o">|</span><span class="n">c</span>: <span class="kt">char</span><span class="o">|</span><span class="w"> </span><span class="o">!</span><span class="p">(</span><span class="n">c</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="sc">'_'</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="sc">'-'</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">c</span><span class="p">.</span><span class="n">is_alphanumeric</span><span class="p">()));</span><span class="w"></span>

<span class="w">        </span><span class="k">for</span><span class="w"> </span><span class="n">token</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">tokens</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">match</span><span class="w"> </span><span class="n">token</span><span class="p">.</span><span class="n">trim</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="s">""</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">                </span><span class="s">"should_panic"</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">data</span><span class="p">.</span><span class="n">should_panic</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="n">seen_rust_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">!</span><span class="n">seen_other_tags</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
<span class="w">                </span><span class="s">"no_run"</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">data</span><span class="p">.</span><span class="n">no_run</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="n">seen_rust_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">!</span><span class="n">seen_other_tags</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
<span class="w">                </span><span class="s">"ignore"</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">data</span><span class="p">.</span><span class="n">ignore</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Ignore</span>::<span class="n">All</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="n">seen_rust_tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">!</span><span class="n">seen_other_tags</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="213742318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213742318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213742318">(Oct 19 2020 at 04:28)</a>:</h4>
<p>Oh wow, I just noticed that you can click on the arrow in the top right of a code snippet and it will open it in the playground! <span aria-label="happy" class="emoji emoji-1f600" role="img" title="happy">:happy:</span></p>



<a name="213742562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213742562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213742562">(Oct 19 2020 at 04:34)</a>:</h4>
<blockquote>
<p>unless you mean "I need to read the rustdoc source"</p>
</blockquote>
<p>Yes, that's what I mean</p>



<a name="213742587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213742587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213742587">(Oct 19 2020 at 04:35)</a>:</h4>
<p>Okay, thanks!</p>



<a name="213846169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213846169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213846169">(Oct 19 2020 at 21:07)</a>:</h4>
<p><code>ignore</code> will still try to highlight the contents as Rust code, so I guess there is a pass of the Rust tokenizer, which <em>can</em> fail (whether that case cpuld have a non-fatal fallback to non-colorized code is another question).<br>
So, in your case I recommend you use <code>text</code> instead of <code>ignore</code> to make sure rustdoc ignores it.</p>



<a name="213854875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213854875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213854875">(Oct 19 2020 at 22:33)</a>:</h4>
<p>oh that rings a bell</p>



<a name="213854892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213854892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213854892">(Oct 19 2020 at 22:33)</a>:</h4>
<p>I think <span class="user-mention silent" data-user-id="133169">matklad</span> recently changed this to use the rustc_lexer instead of handrolling it</p>



<a name="213854899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/213854899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#213854899">(Oct 19 2020 at 22:33)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/75775">https://github.com/rust-lang/rust/pull/75775</a></p>



<a name="214005171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/214005171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#214005171">(Oct 21 2020 at 03:38)</a>:</h4>
<p>I think ignore still ends up as an <code>#[ignore]</code>d doctest. so it still needs to be syntactically valid I've had to resort to </p>
<div class="codehilite"><pre><span></span><code>/// ```
/// # const _: &amp;str = stringify!{
/// invalid snippet here that should still be syntax highlighted
/// # };
/// ```
</code></pre></div>


<p>to get truly ignored text</p>



<a name="214007478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustdoc%20ignore%20not%20working/near/214007478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustdoc.20ignore.20not.20working.html#214007478">(Oct 21 2020 at 04:34)</a>:</h4>
<p>i use <code>txt</code> as the block type sometimes, but then you don't get highlighting</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>